package com.example.agriapp.view.activity;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.agriapp.R;
import com.example.agriapp.data.AgriDatabaseHelper;
import com.example.agriapp.model.bean.Product;
import com.example.agriapp.util.SharedPrefUtils;
import com.example.agriapp.adapter.LiuLanAdapter;

import java.util.List;

public class CartActivity extends AppCompatActivity {

    private RecyclerView recycleView;

    private List<Product> cartItems;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.bottom_nav_icon_selected));

        setContentView(R.layout.activity_cart);
        AgriDatabaseHelper agriDatabaseHelper = new AgriDatabaseHelper(this);
        cartItems = agriDatabaseHelper.getCartItems(SharedPrefUtils.getUserId(this));
        recycleView = findViewById(R.id.recyclerView);
        recycleView.setLayoutManager(new LinearLayoutManager(this));

        recycleView.setAdapter(new LiuLanAdapter(this, cartItems));
        findViewById(R.id.iv_back).setOnClickListener(v -> finish());
    }
}